import { getAcceptAllTime, getPrjDetailApi, getSiteListApi, updateAcceptTimeApi } from '@/api/acceptance'
import { configButtonIsDisplayedApi } from '@/api/acceptanceManagement/acceptanceMange'
import { getQueryObject } from '@/utils'

export const tableMinix = {
  inject: ['prjDetail', 'workDetail'],
  props: {
    prjId: {
      type: String,
      required: true
    }
  },
  data() {
    return {
      params: {
        pageNum: 1,
        pageSize: 10
      },
      tableHeader: [
        {
          label: '项目编码',
          value: 'prjCode'
        },
        {
          label: '项目名称',
          value: 'projectName',
          url: '11'
        },
        {
          label: '项目类型',
          value: 'prjTypeName'
        },
        {
          label: '建设方式',
          value: 'buildModesName'
        },
        {
          label: '站址编码',
          value: 'siteId'
        },
        {
          label: '站址名称',
          value: 'siteName'
        },
        {
          label: '所属管理区域',
          value: 'areaName'
        },
        {
          label: '当前节点',
          value: 'nodeName'
        },
        {
          label: '当前办理人',
          value: 'dealPerson'
        }
      ],
      tableData: [],
      total: 0,
      type: ''
    }
  },
  computed: {
    newPrjDetail() {
      return this.prjDetail()
    },
    newWorkDetail() {
      return this.workDetail()
    }
  },
  methods: {
    async getTable() {
      const params = {
        'prjId': this.newPrjDetail.prjId,
        'ifSingleProject': !['03','05'].includes(this.newPrjDetail.manageMode),
        'workItemId': this.newWorkDetail.workItemID,
        comprehensiveQuery: this.type == '1' ? '1' : '',
        ...this.params
      }
      const result = await getSiteListApi(params)
      this.tableData = result.data.rows
      // 过内验需要用到
      window.sessionStorage.setItem('TableprjInfos', JSON.stringify(this.tableData))
      this.total = result.data.total
    },
    handleData() {
      this.getTable()
    }
  },
  created() {
    const { type } = getQueryObject()
    this.type = type
    if (this.newPrjDetail.startAllProcess) {
      this.tableHeader = [
        ...this.tableHeader,
        {
          label: '验收流程状态',
          value: 'ifStartAccProcess'
        },
        {
          label: '操作',
          value: 'operate'
        }
      ]
    }
    this.getTable()
  }
}
